﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Sprout.Core.Paging
{
    public class PagedList<T>
    {
        /// <summary>
        /// 总行数
        /// </summary>
        public int TotalCount { get; set; }

        private int pageSize = 0;
        public int PageSize
        {
            get
            {
                return pageSize;
            }
            set
            {
                pageSize = value;
            }
        }
        /// <summary>
        /// 分页数据
        /// </summary>
        public IList<T> PageData { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int TotalPages
        {
            get
            {
                if (pageSize == 0)
                {
                    return 0;
                }
                else
                {
                    if (TotalCount % pageSize == 0)
                    {
                        return TotalCount / pageSize;
                    }
                    else
                    {
                        return TotalCount / pageSize + 1;
                    }
                }
            }
        }
    }
}
